<div class="row">
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
		<h1 class="page-title txt-color-blueDark"><i class="fa-fw fa fa-group"></i> {:W('Nav/navTop')}
		</h1>

	</div>
	</div>
<!-- row -->
				<div class="row">

					<div class="col-sm-12">

						

						<div class="well">
							<form action="{:U(APP_CONTROLLE/APP_NAME)}&id={:I('get.id')}" id="role-form" role="form" method="post" class="smart-form">
							<fieldset>	
							<volist name="data" id="vo">
								<?php if($vo['is_edit'] == 0) continue;?>
								<if condition="$vo['type'] eq 'text'">
									<div class="row">			
										<section class="col col-6">		
											<label class="label">{$vo.name}</label>
												<label class="input">
												<input type="text" class="{$vo.class}" name="{$vo.us_name}" value="{$rel[$vo['us_name']]}">
												<b class="tooltip tooltip-bottom-left">请填写{$vo.name}</b>
												</label>
											</section>
									</div>
								<elseif condition="$vo['type'] eq 'text_img'" />
									<div class="row">			
										<section class="col col-6">		
											<label class="label">{$vo.name}</label>
												<label class="input">
												<input type="text" class="upload_img" name="{$vo.us_name}" value="{$rel[$vo['us_name']]}">
												<b class="tooltip tooltip-bottom-left">请填写{$vo.name}</b>
												<div style="border: none" class="input-group smart-form form-control">
												    <section>
												        <label for="file" class="input input-file">
												            <div class="button">
												                <input type="file" id="tmpfile" name="photo"  multiple="true" />上传
												            </div>
												        </label>
												    </section>
												</div>

												</label>
											</section>
											<img style="width:100px" class="upload_img_show" src="{$rel[$vo['us_name']]}" />
									</div>
								<elseif condition="$vo['type'] eq 'datetime'" />
									<div class="row">			
										<section class="col col-6">		
											<label class="label">{$vo.name}</label>
												<label class="input">
												<input type="datetime" name="{$vo.us_name}" class="form-control form_datetime" id="time_begin_{$i}" placeholder="{$vo.name}" value="{$rel[$vo['us_name']]}">
												<!-- <b class="tooltip tooltip-bottom-left">请填写{$vo.name}</b> -->
											</label>
										</section>
									</div>
								<elseif condition="$vo['type'] eq 'textarea'" />


									<div class="row">			
											<section class="col col-6">
											<label class="label">{$vo.name}</label>
												<label class="textarea">
												<textarea rows="3" name="{$vo.us_name}">{$rel[$vo['us_name']]}</textarea>
												<b class="tooltip tooltip-bottom-left">请填写{$vo.name}</b>
												</label>
											</section>
									</div>
								<elseif condition="$vo['type'] eq 'textarea2'" />
											<!-- end row -->
								<script type="text/javascript" src="{$Think.config.SUB_PATH}ueditor/ueditor.config.js"></script>
								<script type="text/javascript" src="{$Think.config.SUB_PATH}ueditor/ueditor.all.js"></script>
								<script type="text/javascript">
									var ue = UE.getEditor('container');
								</script>
									<div class="row">			
											<section class="col col-6">
											<label class="label">{$vo.name}</label>
	                                        <div class="col-md-10">
	                                            <script type="text/plain" id="container" name="{$vo.us_name}">{:htmlspecialchars_decode($rel[$vo['us_name']], ENT_QUOTES )}</script>
	                                            
	                                           <!--  <textarea rows="2" name="content" id="content" placeholder="" class="form-control">{$data.content}</textarea>-->
	                                        </div>
											</section>
									</div>
								<elseif condition="$vo['type'] eq 'select'" />
									<div class="row">
										<section class="col col-6">
											<label class="label">{$vo.name}</label>
											<label class="select">
												<select name="{$vo.us_name}" >
													{$select_data}
												</select>
												<b class="tooltip tooltip-bottom-left">
													请填写{$vo.name}
												</b>
											</label>
										</section>
									</div>
								<elseif condition="$vo['type'] eq 'redio'" />
									<div class="row">			
										<section class="col col-6">		
											<label class="col-md-2 control-label">{$vo.name}:</label>
												    <!-- <input type="checkbox"  name="{$vo.us_name}" class="checkbox style-2" <?php if($rel[$vo['us_name']] == 1){ echo 'checked';}?> />
												    <span>
												        是
												    </span> -->
												    <div class="col-md-1">
												        <label class="radio radio-inline">
												            <input type="radio" class="radiobox style-2" value="1" name="{$vo.us_name}" <?php if($rel[$vo['us_name']] == 1){ echo ' checked="checked"';}?> />
												            <span>
												                是
												            </span>
												        </label>
												    </div>
												    <div class="col-md-1">
												        <label class="radio radio-inline">
												            <input type="radio" class="radiobox style-2"  value="0" name="{$vo.us_name}" <?php if($rel[$vo['us_name']] == 0){ echo ' checked="checked"';}?> />
												            <span>
												                否
												            </span>
												        </label>
												    </div>
											</section>
									</div>

								</if>	

							</volist>
							</fieldset>
							<footer>
								<section class="col col-6">
								<input type="hidden" name="dosubmit" value='1'/>
								<button type="submit" class="btn btn-primary">
									{:L('cms_submit')}
								</button>
								</section>	
								</footer>
							</form>
							</div>
					</div>
				</div>
			

<script>

//做一些清理工作
$(".DTTT_dropdown").remove();
$('.ui-dialog').remove();
$('.datetimepicker').remove();

$(document).ready(function() {
	
	$('#role-form').ajaxForm(function(data) { 
		if(data.status==200){
       	 	showhidetip(data.msg,2);
       	 	window.location.href="{$Think.config.SUB_PATH}#{$Think.config.SUB_PATH}index.php?m=admin&c={:CONTROLLER_NAME}&a=index";return false;
       	}else if(data){
       		showhidetip(data.msg,2);return false;
       	}else{
       		showhidetip("{:L('cms_other_error')}",2);return false;
       	}
});

	
	// var ue = UE.getEditor('container');
	
	
	$('#add-form').submit(function(){
	    $(this).ajaxSubmit(function(data) {     
	        if( data.status==200 ){
	            window.history.go(-1);
	        }else{
	            alert(data.msg);
	        }
	    });
	    return false;
	});
});
</script>
<script type="text/javascript">

    
    var ajaxUploadUrl = "{:U("Common/upload")}";
    
    $('#tmpfile').uploadify({
        'formData'     : {
            'timestamp' : '<?php echo $timestamp;?>',
            'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
        },
        'swf'      : './js/uploadify/uploadify.swf',
        'uploader' : ajaxUploadUrl,
        'auto':true,
        'multi':false,
        'buttonText':"上传",
        'width':30,
        'onUploadSuccess' : function(file, data, response) {
            data = eval("("+data+")");;
            //alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
            var img_url = data.content;
            $("#tmpfile").parent().siblings('input').eq(0).val(img_url);
        }
    });
    /**
     * 上传图片
     */
    /*function ajax_upload(files, obj){
        if(files == null) return;
        $(files).each(function(a,file){
            //提供一个可以取消的能力
            window.xhr = $.ajaxSettings.xhr();
            //事件函数
            var onProgressHandler = function(event){
                if(event.loaded) {
                    var howmuch = Math.floor((event.loaded / event.total) * 100);
                }else{
                      
                }
            };
            var onLoadedHandler = function(msg){
                
            };
            var onAbortHandler = function(){
            };
            //事件绑定
            xhr.upload.addEventListener('progress', onProgressHandler, false);
            xhr.upload.addEventListener('load', onLoadedHandler, false);
            xhr.upload.addEventListener('abort', onAbortHandler, false);

            xhr.onreadystatechange = function(event){
                if(event.target.readyState == 4 && event.target.status == 200){
                    var text = $.parseJSON(event.target.responseText);
                    logincheck(text);
                    if(text.status == 200){
                        $(obj).parent().nextAll('input').eq(0).val(text.content.pic_url);
                        var $div = $(obj).parents('.pic-div').next('div');
                        $div.find('.up_img_show').html('<a href="'+text.content.src+'" target="_blank"><img src="'+text.content.src+'" style="width:48px;" /></a><a href="javascript:void(0);" onclick="_clean_img(this);return false;" class="up_img_del"><i class="glyphicon glyphicon-remove"></i></a>');
                    }else{
                        warningBox(text.msg);
                    }
                }
            };
            xhr.open('post',ajaxUploadUrl + "&filename=" + file.name,true);
            //xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xhr.setRequestHeader("Content-Type", "multipart/form-data");
            xhr.send(file);
        });
        return false;
    }*/

</script>


